package com.xs.bookspoststation.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.xs.bookspoststation.R;
import com.xs.bookspoststation.bean.Book;

import java.util.List;

public class BookAdapter extends ArrayAdapter {

    //实体类
    Book book;

    public void setUser(Book book) {
        this.book = book;
    }

    @Override
    public long getItemId(int position){
        return position;

    }

    public BookAdapter(Context context, int resource, List<Book> bookList) {
        super(context, resource, bookList);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent){
        book = (Book) getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(R.layout.booklist, null);

        TextView book_sel_bookid =(TextView)view.findViewById(R.id.book_sel_bookid);
        TextView book_sel_bookname =(TextView)view.findViewById(R.id.book_sel_bookname);
        TextView book_sel_booknumber =(TextView)view.findViewById(R.id.book_sel_booknumber);
        TextView book_sel_bookauthor =(TextView)view.findViewById(R.id.book_sel_bookauthor);
        TextView book_sel_bookshow =(TextView)view.findViewById(R.id.book_sel_bookshow);
        book_sel_bookid.setText(book.getBookid());
        book_sel_bookname.setText(book.getBookname());
        book_sel_booknumber.setText(book.getBooknumber());
        book_sel_bookauthor.setText(book.getBookauthor());
        book_sel_bookshow.setText(book.getBookshow());
        return view;

    }
}
